home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / bin / post.c < prev    next >
C/C++ Source or Header  |  1999-12-06  |  3KB  |  104 lines

  1. #include <pragma/noviasys_lib.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/dos_lib.h>
  4. #include <stdio.h>
  5. #include <novia/novia_portdata.h>
  6.  
  7. struct Library *NoviaSysBase;
  8.  
  9. void ioprintf(const char *string, ...)
  10. {
  11.     char *buffer=AllocVec(10000,MEMF_ANY|MEMF_CLEAR);
  12.     if (buffer)
  13.     {
  14.         vsprintf(buffer, string, unsigned int(&string + 1));
  15.         Writeio(buffer,-1);
  16.         FreeVec(buffer);
  17.     }
  18. }
  19.  
  20. void main()
  21. {
  22.     if ((NoviaSysBase = OpenLibrary("noviasys.library", 0)))
  23.     {
  24.         struct PortData *cport = (struct PortData *)FindTask(NULL)->tc_UserData;
  25.             Getstring(buffer,0,50,0,0);
  26.             if (strlen(buffer)>=3)
  27.             {
  28. //                VisualEditor("ram:temp");
  29.                 {
  30.                     BPTR mulder;
  31.                     if ((mulder = Open("ram:temp",MODE_OLDFILE)))
  32.                     {
  33.                         Seek(mulder,0,OFFSET_END);
  34.                         if ((ulong = Seek(mulder,0,OFFSET_BEGINNING)))
  35.                         {
  36.                             struct NewItem *newitem;
  37.                             if ((newitem = AllocVec(sizeof(NewItem),MEMF_ANY|MEMF_CLEAR)))
  38.                             {
  39.                                 if ((newitem->text = AllocVec(ulong+1,MEMF_ANY)))
  40.                                 {
  41.                                     if (Read(mulder, newitem->text, ulong))
  42.                                     {
  43.                                         char quit = FALSE;
  44.                                         newitem->ItemType            = ITEMTYPE_MESSAGE;
  45.                                         GetTime(&newitem->CreateDate);
  46.                                         newitem->Protection        = FIBF_READ | FIBF_WRITE | FIBF_EXECUTE | FIBF_DELETE;
  47.                                         newitem->CreateUserIP    = cport->LocalUser.IPNumber;
  48.                                         newitem->FromUser            = cport->LocalUser.IDNumber;
  49.                                         ioprintf("Write as anonymous ? ");
  50.                                         if (Yesno(FALSE,0))
  51.                                         {
  52.                                             newitem->anonymous = TRUE;
  53.                                         }
  54.                                         else
  55.                                         {
  56.                                             ioprintf("Write as alias ? ");
  57.                                             if (Yesno(FALSE,0))
  58.                                             {
  59.                                                 ioprintf("Enter the SENDER's Username [ENTER=YOU]\n:");
  60.                                                 Getstring(newitem->Alias,0,60,0,0);
  61.                                             }
  62.                                         }
  63.                                         strncpy(newitem->Subject,        buffer,70);
  64. //                                        Filename[108]
  65.                                         strncpy(newitem->From,            cport->LocalUser.Handle,sizeof(newitem->From)-1);
  66.                                         strncpy(newitem->FromRealName,    cport->LocalUser.RealName,sizeof(newitem->FromRealName)-1);
  67.                                         while (!quit)
  68.                                         {
  69.                                             ioprintf("Enter the ADDRESS handle [ENTER=ALL]\n:");
  70.                                             Getstring(newitem->To,0,20,0,0);
  71.                                             if (strlen(newitem->To))
  72.                                             {
  73.                                                 if ((newitem->ToUser = SearchUser(newitem->To)))
  74.                                                 {
  75.                                                     strncpy(newitem->To,            cport->UL.utable[newitem->ToUser].Handle,sizeof(newitem->To)-1);
  76.                                                     strncpy(newitem->ToRealName,cport->UL.utable[newitem->ToUser].RealName,sizeof(newitem->ToRealName)-1);
  77.                                                     quit = TRUE;
  78.                                                 }
  79.                                                 else
  80.                                                 {
  81.                                                     ioprintf("%s is not a user of this system. use anyway ?");
  82.                                                     if (Yesno(FALSE,0))
  83.                                                         quit = TRUE;
  84.                                                 }
  85.                                             }
  86.                                             else
  87.                                                 quit = TRUE;
  88.                                         }
  89. //                                        MailListMail
  90. //                                        MailListID
  91.                                         ioprintf("errror: %d\n",ndos_addmail(newitem));
  92.                                     }
  93.                                     FreeVec(newitem->text);
  94.                                 }
  95.                                 FreeVec(newitem);
  96.                             }
  97.                         }
  98.                         Close(mulder);
  99.                     }
  100.                 }
  101.             }
  102.         CloseLibrary(NoviaSysBase);
  103.     }
  104. }